import sys,time,os
from PyQt5.QtCore import pyqtSlot,QObject,pyqtSignal
from  PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QApplication,QMainWindow,QWidget
from score import *

class MainWin(QMainWindow,Ui_MainWindow,QWidget):
	def __init__(self,parent = None):
		super(MainWin,self).__init__(parent)
		self.setupUi(self)
		self.refresh()
		self.pushButton.clicked.connect(self.refresh)
		self.clean.clicked.connect(self.clean_)

	def refresh(self):
		a = ''
		k = 1
		try:
			with open('score.txt','r') as file:
				text = file.readlines()
			for i in text:
				a += '%d\t%s'%(k,i)
				k+=1
			self.textBrowser.setText(a)
		except:
			self.textBrowser.setText('')

	def clean_(self):
		try:
			os.remove('score.txt')
		except FileNotFoundError:
			pass
		self.refresh()

if __name__ == '__main__':
	app = QApplication(sys.argv)
	Win = MainWin()
	Win.show()
	sys.exit(app.exec_())